function Vector(x, y){
	this.x = x;
	this.y = y;
}

Vector.prototype = {
	// 向量的模
	getMagnitude: function(){
		return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
	},

	// 向量相加
	add: function(vector){
		var v = new Vector();

		v.x = this.x + vector.x;
		v.y = this.y + vector.y;

		return v;
	},

	// 向量相减
	subtract: function(vector){
		var v = new Vector();

		v.x = this.x - vector.x;
		v.y = this.y - vector.y;

		return v;
	},

	// 点积
	dotProduct: function(vector){
		return this.x * vector.x + this.y * vector.y;
	},

	// 边界
	edge: function(vector){
		return this.subtract(vector);
	},

	// 获得与之相对的垂直向量
	perpendicular: function(){
		var v = new Vector();

		v.x = this.y;
		v.y = 0 - this.x;

		return v;
	},

	// 获取单位向量
	normalize: function(){
		var v = new Vector(),
			m = this.getMagnitude;

		if(m != 0){
			v.x = this.x / m;
			v.y = this.y / m;
		}

		return v;
	},

	// 获取垂直向量的单位向量
	normal: function(){
		var p = this.perpendicular();

		return p.normalize();
	}
};